<%--
  Created by IntelliJ IDEA.
  User: dengdc
  Date: 2017/7/19
  Time: 17:09
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="s" uri="http://www.springframework.org/tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <title>diyishou </title>
    <jsp:include page="../../head.jsp"/>
    <script type="text/javascript">
//        <!--申报报关行	业务类型	计费条件	费用类型	支出对象	费用名称	计费规则	计费规则说明	起算数量	单价	封顶价	成本价	是否有效	费用描述	有效时间从	有效时间至-->
        var formSetting = {
            title: "查询信息",
            module: 'query',
            columns: [{
                name: "ieType",
                label: "进出口类型",
                type: "dropdown",
                data: [["进口", "I"], ["出口", "E"]],
                op: "eq",
                minLength: 0
            }, {
                name: "contractNo",
                label: "合同协议号"
            }, {
                name: "businessNo",
                label: "业务编号"
            }, {
                name: "containerNo",
                label: "集装箱号"
            }, {
                name: "companyCo",
                label: "收发货人",
                type: "dropdown",
                dropdownType: "ajax",
                url: "<s:url value='/order-dropdown/company'/>",
                op: "eq",
                minLength: 1,
                keyWordName: "key",
                success: function (data) {
                    data = data.results;
                    var array = new Array();
                    $.each(data, function (i, n) {
                        array.push([n["text"], n["value"]]);
                    });
                    return array;
                }
            }, {
                name: "billNo",
                label: "提运单号"
            },{
                name: "supComId",
                label: "业务供应商",
                type: "dropdown",
                dropdownType: "ajax",
                url: "<s:url value='/order-dropdown/supCompany'/>",
                op: "eq",
                minLength: 1,
                keyWordName: "key",
                success: function (data) {
                    data = data.results;
                    var array = new Array();
                    $.each(data, function (i, n) {
                        array.push([n["name"], n["value"]]);
                    });
                    return array;
                }
            }],
            buttons: {
                custom: []
            },
            grid: {
                id: "originalDeclarationGrid",
                title: "查询结果",
                url: "getListPageData",
                colModel: [{
                    index: "id",
                    name: "id",
                    formatter:function(val, colModel, rowObj){
                        return rowObj.ID;
                    },
                    hidden: true
                }, {
                    index: "DID",
                    name: "DID",
                    hidden: true
                },{
                    name: "BUSINESSNO",
                    label: "业务编号"
                }, {
                    name: "CONTAINERNO",
                    label: "集装箱号"
                }, {
                    name: "CONTRACTNO",
                    label: "合同协议号"
                }, {
                    name: "IETYPE",
                    label: "进出口",
                    formatter:function (val, opts, rowObj) {
                        if(!val){
                            return "";
                        }
                        if("I" === val){
                            return "进口";
                        }else{
                            return "出口";
                        }
                    }
                }, {
                    name: "BILLNO",
                    label: "提运单号"
                }, {
                    name: "SHOUFAHUOREN",
                    label: "收发货人"
                }, {
                    name: "SUPCOMNAME",
                    label: "业务供应商"
                }, {
                    name: "PORT",
                    label: "申报口岸"
                }, {
                    name: "SUBMITTIME",
                    label: "下单时间"
                }, {
                    name: "MODIFIER",
                    label: "下单人"
                }, {
                    name:"PDF",
                    hidden:true
                }, {
                    name:" ",
                    label:"PDF格式下载",
                    sortable:false,
                    formatter:function(val, opts, rowObj){
                        return "<input value='下载' type='button' onclick='ckd(\""+rowObj.ID+"\")'/>";
                    }
                }]
            }
        };
        $(document).ready(function () {
            $("#table").mrdForm(formSetting);
        });
        function ckd(rowid){
            var rows = $("#originalDeclarationGrid").gridMethods().getAllRowData();
            var rowData = {};
            for (var i = 0; i < rows.length; i++) {
                var r = rows[i];
                if(rowid === r.id){
                    rowData = r;
                    break;
                }
            }
             var url = '<s:url value="/original/declaration/download"/>?date='+rowData.SUBMITTIME+'&pdfName='+rowData.PDF+'&originalId='+rowid;
             $.download(url);
        }
    </script>
</head>
<body>
<div id="table"></div>
</body>
</html>
